// ============================== 导入依赖 ============================== //

import CORE from '@/CORE'

const EMPTY = [
  {
    groupName: '-',
    fileList: [
      {
        name: '-',
        size: '-',
        memo: '-',
        icon: '',
        path: '',
        qrcode: '',
      },
    ],
  },
]

// ============================== 导出远程接口 ============================== //

export default {
  // —————————————————————————————— 列表 —————————————————————————————— //

  async getList(param, TIP = '查询列表') {
    let list = EMPTY
    try {
      const resp = await CORE.loadJSON(CORE.asset('DOWNLOAD.json'))
      if (CORE.isArray(resp) && resp.length) list = resp
    } catch (e) {
      //
    }
    return [list.length, list]
  },
  transList(arr) {
    arr.forEach((item) => {
      const suffix = (/(\.\w+)$/.exec(item.path) || [])[1] || '' // 后缀
      item.download = `${item.name}${suffix}`
    })
    return arr
  },
}
